package com.mvp.shq.washer.ui.faultFeedBack;

import com.mvp.shq.washer.entity.result.BaseResult;
import com.mvp.shq.washer.http.BaseObserver;
import com.mvp.shq.washer.utils.SpUtil;

/**
 * Created by Administrator on 2017/9/6.
 */

public class Presenter extends FaultFeedBackConstract.Presenter {
    @Override
    public void onStart() {

    }

    @Override
    void faultFeedBack(String washerNo, String content) {
        String token = SpUtil.getToken();
        String userId = SpUtil.getUser().getId();
        model.faultFeedBack(token,userId,washerNo,content)
                .subscribe(new BaseObserver<String>(view) {
                    @Override
                    protected void onSuccees(BaseResult<String> t) throws Exception {
                        if (t.isError()){
                            view.feedBackF(t.getMsg());
                        }else {
                            view.feedBackS();
                        }
                    }

                    @Override
                    protected void onFailure(Throwable e, boolean isNetWorkError) throws Exception {
                        e.printStackTrace();
                        view.feedBackF("未知错误");
                    }
                });
    }
}
